//
//  HomeTabBarController.m
//  SXCustomer
//
//  Created by 杨康 on 16/8/16.
//  Copyright © 2016年 杨康. All rights reserved.
//


#import "SystemViewController.h"




@interface SystemViewController ()
@end
@implementation SystemViewController



- (void)viewDidLoad
{
    [super viewDidLoad];
    
    HomeViewController * homeVC = [[HomeViewController alloc] init];
    AccountViewController *accountVC=[[AccountViewController alloc]init];
    
    MyViewController  * myVC = [[MyViewController alloc] init];
    
    
    ElectrombileViewController *eleVC=[[ElectrombileViewController alloc]init];
    
    
    TypeColorViewController *cBrandVC=[[TypeColorViewController alloc]init];
    
    AccountManageViewController *aManageVC=[[AccountManageViewController alloc]init];

    BaseNavViewController * homeNC = [self setUpOneController:homeVC title:@"管理" image: [UIImage imageNamed:@"管理1"] selectImage: [UIImage imageNamed:@"管理"]];
    
    BaseNavViewController * accountNC = [self setUpOneController:accountVC title:@"账户" image: [UIImage imageNamed:@"账户1"] selectImage: [UIImage imageNamed:@"账户"]];
    
    BaseNavViewController*myNC = [self setUpOneController:myVC title:@"我的" image: [UIImage imageNamed:@"我的1"] selectImage: [UIImage imageNamed:@"我的"]];
    
    
    BaseNavViewController*eleNC = [self setUpOneController:eleVC title:@"电动车" image: [UIImage imageNamed:@"电动车1"] selectImage: [UIImage imageNamed:@"电动车"]];
    
    BaseNavViewController*cBrandNC = [self setUpOneController:cBrandVC title:@"厂商" image: [UIImage imageNamed:@"厂商1"] selectImage: [UIImage imageNamed:@"厂商"]];
    
    BaseNavViewController*aManageNC = [self setUpOneController:aManageVC title:@"账户" image: [UIImage imageNamed:@"账户1"] selectImage: [UIImage imageNamed:@"账户"]];
    
    //管理员
    NSArray *arrayControllers = [NSArray arrayWithObjects:homeNC,accountNC,myNC, nil];
    
    //门店
    NSArray *arrayControllers2 = [NSArray arrayWithObjects:eleNC,myNC, nil];
    
    
    //电动车厂商
    NSArray *arrayControllers3 = [NSArray arrayWithObjects:cBrandNC,eleNC,myNC, nil];
    
    //民警
    NSArray *arrayControllers4 = [NSArray arrayWithObjects:eleNC,aManageNC,myNC, nil];
    
    //物业
    NSArray *arrayControllers5 = [NSArray arrayWithObjects:eleNC,myNC, nil];
    
    
    if ([APPTOKEN isEqualToString:@"admin"]) {
        self.viewControllers = arrayControllers;
    }
    else if ([APPTOKEN isEqualToString:@"shop"])
    {
        self.viewControllers = arrayControllers2;
    }
    else if ([APPTOKEN isEqualToString:@"producer"])
    {
        self.viewControllers = arrayControllers3;
    }
    else if ([APPTOKEN isEqualToString:@"police"])
    {
        self.viewControllers = arrayControllers4;
    }
    else if ([APPTOKEN isEqualToString:@"property"])
    {
        self.viewControllers = arrayControllers5;
    }
    else if ([APPTOKEN isEqualToString:@"repair"])
    {
        
    }
    
    
    self.tabBar.backgroundColor=[UIColor whiteColor];
    self.tabBar.tintColor = [UIColor colorQ];
    [UITabBar appearance].translucent = NO;
    [[UITabBar appearance] setBarTintColor:[UIColor whiteColor]];
    
    
    
    
}


- (BaseNavViewController*)setUpOneController:(UIViewController*)vc title:(NSString*)title image:(UIImage*)image selectImage:(UIImage*)selectImage
{
    
    if( ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0))
    {
        
        [vc setAutomaticallyAdjustsScrollViewInsets:NO];
        
    }
   
    
    
    BaseNavViewController*naVC = [[BaseNavViewController alloc] initWithRootViewController:vc];
   
    naVC.tabBarItem.title = title;
    naVC.tabBarItem.image = image;
    naVC.tabBarItem.selectedImage = [selectImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    
    
    
    
//    if ([title isEqualToString:@"首页"]) {
//        NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor grayColor],NSForegroundColorAttributeName, nil];
//        [naVC.tabBarItem setTitleTextAttributes:dict forState:UIControlStateNormal];
//        
//        NSDictionary *dict2 = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:0.0f/255.0f green:180.0f/255.0f blue:237.0f/255.0f alpha:1.0],
//                               NSForegroundColorAttributeName,nil];
//        [naVC.tabBarItem setTitleTextAttributes:dict2 forState:UIControlStateSelected];
//    }else if ([title isEqualToString:@"发现"])
//    {
//        NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor grayColor],NSForegroundColorAttributeName, nil];
//        [naVC.tabBarItem setTitleTextAttributes:dict forState:UIControlStateNormal];
//        
//        NSDictionary *dict2 = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:255.0f/255.0f green:199.0f/255.0f blue:30.0f/255.0f alpha:1.0],
//                               NSForegroundColorAttributeName,nil];
//        [naVC.tabBarItem setTitleTextAttributes:dict2 forState:UIControlStateSelected];
//    }
//    else if ([title isEqualToString:@"我的"])
//    {
//        NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor grayColor],NSForegroundColorAttributeName, nil];
//        [naVC.tabBarItem setTitleTextAttributes:dict forState:UIControlStateNormal];
//        
//        NSDictionary *dict2 = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:84.0f/255.0f green:168.0f/255.0f blue:255.0f/255.0f alpha:1.0],
//                               NSForegroundColorAttributeName,nil];
//        [naVC.tabBarItem setTitleTextAttributes:dict2 forState:UIControlStateSelected];
//    }
    return naVC;
}





@end
